package com.lancoo.znbkxx.teacher.aibkTestCoach.studyAnalysis

import android.content.Context
import android.content.res.TypedArray
import android.graphics.*
import android.util.AttributeSet
import android.view.View
import com.lancoo.znbkxx.teacher.R

/**
 * Created by Dadong on 2021/2/22
 * Describe:
 */
class InstructLineView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {

    private var mPaint = Paint()

    init {
        //获取自定义属性。
        val typedArray: TypedArray = context!!.obtainStyledAttributes(attrs, R.styleable.InstructView)
        var paintColor = typedArray.getColor(R.styleable.InstructView_paintcolor, Color.BLACK)
        typedArray.recycle()
        mPaint.color = paintColor
    }

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        mPaint.isAntiAlias = true
        mPaint.style = Paint.Style.FILL
        mPaint.strokeWidth = 2f
        var rect = Rect(0, 0, 20, 20)
        canvas!!.drawRect(rect, mPaint)
        mPaint.style = Paint.Style.STROKE
        var path = Path()
        path.moveTo(20f, 20f)
        path.lineTo(28f, 28f)
        path.lineTo(250f, 28f)
        canvas.drawPath(path, mPaint)
    }

    public fun setPaintColor(color: Int) {
        mPaint.color = color
    }
}